<template>
	<!-- 添加或修改保密等级变更记录对话框 -->
	<el-dialog :title="dialogTitle" :visible.sync="visible" width="560px" append-to-body>
		<el-form ref="form" :model="formData" :rules="formRules" label-width="86px">
			<el-row :gutter="16">
				<el-col :span="24">
					<el-form-item label="保密人员" prop="userId">
						<person-select v-model="formData.userId" :list="checkedUsers" :disabled="isDisabled"></person-select>
					</el-form-item>
				</el-col>
				<el-col :span="11">
					<el-form-item label="原保密等级" prop="sourceLevel">
						<el-select v-model="formData.sourceLevel" placeholder="选择原保密等级" disabled style="width: 100%">
							<el-option v-for="(item, index) in dict.type.sp_level" :key="index" :label="item.label" :value="item.value"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="13">
					<el-form-item label="目标保密等级" prop="targetLevel" label-width="110px">
						<el-select v-model="formData.targetLevel" placeholder="选择目标保密等级" style="width: 100%">
							<el-option v-for="(item, index) in dict.type.sp_level" :key="index" :label="item.label" :value="item.value"></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="11">
					<el-form-item label="变更时间" prop="changeDate">
						<el-date-picker v-bind="dateConfig" v-model="formData.changeDate" type="date" value-format="yyyy-MM-dd"></el-date-picker>
					</el-form-item>
				</el-col>
				<el-col :span="13">
					<el-form-item label="是否需要审批" prop="isAudit" label-width="110px">
						<el-radio-group v-model="formData.isAudit" aria-hidden>
							<el-radio v-for="(item, index) in dict.type.sys_yes_no" :key="index" :label="item.value">{{ item.label }}</el-radio>
						</el-radio-group>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="变更理由" prop="des">
						<el-input v-model="formData.des" type="textarea" :autosize="{ minRows: 2, maxRows: 4 }" placeholder="请输入变更理由"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
		<template slot="footer">
			<el-button type="primary" @click="handleSubmitData()">确定</el-button>
			<el-button @click="visible = false">取消</el-button>
		</template>
	</el-dialog>
</template>

<script>
import formMixins from '../common/formMixins';
import { getLevel, addLevel, updateLevel } from '@/api/personnal/grade';
export default {
	mixins: [formMixins],
	dicts: ['sp_level', 'sys_yes_no'],
	data() {
		return {
			formName: '等级变更',
			formRules: {
				userId: { required: true, message: '请选择保密人员', trigger: 'change' },
				targetLevel: { required: true, message: '请选择目标保密等级', trigger: 'change' },
				changeDate: { required: true, message: '请选择变更时间', trigger: 'change' },
				isAudit: { required: true, message: '请选择是否需要审批', trigger: 'change' },
				des: { required: true, message: '请填写变更理由', trigger: 'blur' }
			},
			dateConfig: {
				type: 'date',
				editable: false,
				style: { width: '100%' },
				valueFormat: 'yyyy-MM-dd',
				placeholder: '选择变更时间'
			}
		};
	},
	computed: {
		detailFunction() {
			return eval(getLevel);
		},
		callFunction() {
			return eval(this.addOrEdit ? addLevel : updateLevel);
		}
	},
	watch: {
		userDetail(data) {
			this.$set(this.formData, 'userName', data.name);
			this.$set(this.formData, 'sourceLevel', data.spLevel);
		}
	},
	methods: {
		//格式化请求参数
		formatRequestParams() {
			let params = { ...this.formData };
			return params;
		}
	}
};
</script>

<style scoped></style>
